<!doctype html>
<html>
<head>
	<meta charset="UTF-8">
	<title>后台登录-狂雨小说CMS</title>
	<meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<link rel="stylesheet" href="__ADMIN__/css/admin.css">
</head>
<body class="login-bg">
    <div class="login">
        <div class="message">狂雨小说CMS-管理登录</div>
        <div id="darkbannerwrap"></div>
        <form method="post" class="layui-form">
            <input name="username" placeholder="用户名"  type="text" lay-verify="required">
            <hr class="hr15">
            <input name="password" placeholder="密码"  type="password" lay-verify="required">
            <hr class="hr15">
            <input name="code" placeholder="验证码"  type="text" lay-verify="required" style="width: 150px;">
            <img src="{:url('admin/index/verify')}" class="verify">
            <hr class="hr15">
            <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
            <hr class="hr20" >
        </form>
    </div>
    <script type="text/javascript" src="__STATIC__/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="__ADMIN__/lib/layui/layui.js"></script>
    <script type="text/javascript" src="__ADMIN__/js/admin.js"></script>
    <script>
        $(function(){
            layui.use('form', function(){
              var form = layui.form;
              //监听提交
              form.on('submit(login)', function(data){
                $.post('{:url('admin/index/login')}',data.field, function(data){
                    if(data.code){
                        window.location.href = data.url;
                    } else {
                        layer.msg(data.msg, {icon: 0});
                        $(".layui-form")[0].reset();
                        //刷新验证码
                        $(".verify").click();
                    }
                }, "json");
                return false;
              });
            });

            var verifyimg = $(".verify").attr("src");
            $(".verify").click(function(){
                if( verifyimg.indexOf('?')>0){
                    $(".verify").attr("src", verifyimg+'&random='+Math.random());
                }else{
                    $(".verify").attr("src", verifyimg.replace(/\?.*$/,'')+'?'+Math.random());
                }
            });
        })
    </script>
    <!-- 底部结束 -->
</body>
</html>